<template>
  <view class="container">
    <view class="control-wheel-container" >
      <!-- 外圆 -->
      <view class="wheel-outer">
        <!-- 中心圆 -->
        <!-- <view class="wheel-inner" >
          <text class="wheel-icon"></text>
        </view> -->
        
        <!-- 方向按钮 stop, up, down, left, right, zoomin, zoomout -->
        <view class="direction-btn direction-up" @touchstart="handleDirection('up')" @touchend="handleDirection('stop')">
          <text class="direction-icon">↑</text>
        </view>
        <view class="direction-btn direction-right" @touchstart="handleDirection('right')"  @touchend="handleDirection('stop')">
          <text class="direction-icon">→</text>
        </view>
        <view class="direction-btn direction-down" @touchstart="handleDirection('down')"  @touchend="handleDirection('stop')">
          <text class="direction-icon">↓</text>
        </view>
        <view class="direction-btn direction-left" @touchstart="handleDirection('left')"  @touchend="handleDirection('stop')">
          <text class="direction-icon">←</text>
        </view>
      </view>
    </view>
    
    <!-- 缩放控制 -->
    <view class="zoom-controls">
      <view class="zoom-btn zoom-in" @touchstart="handleDirection('zoomin')" @touchend="handleDirection('stop')">
        <text class="zoom-icon">+</text>
      </view>
      <view class="zoom-btn zoom-out" @touchstart="handleDirection('zoomout')" @touchend="handleDirection('stop')">
        <text class="zoom-icon">-</text>
      </view>
    </view>
    
  </view>
</template>

<script>
import {
	cameraPtz
} from '@/api/mine/equipment'
export default {
  props:{
	deviceId:{
		type: String
	}  
  },
  data() {
    return {
      isDragging: false,
      wheelRadius: 120, // 外圆半径
      innerRadius: 40,  // 内圆半径
      maxOffset: 80,    // 最大偏移量 (wheelRadius - innerRadius)
	  isPtz: false //是否正在操作
    }
  },
  computed: {
  },
  methods: {
    handlePtz(ptz){
		cameraPtz({id:this.deviceId,ptz:ptz})
		.then(res=>{
			console.log("操作成功")
		})
	},
    handleDirection(ptz) {
		this.handlePtz(ptz)
    }
  }
}
</script>

<style scoped lang="scss">
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30rpx;
}

.control-wheel-container {
  position: relative;
  width: 300rpx;
  height: 300rpx;
  margin: 50rpx 0;
}

.wheel-outer {
  position: relative;
  width: 300rpx;
  height: 300rpx;
  border-radius: 50%;
  background-color: rgba(200, 200, 200, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.2);
}

.wheel-inner {
  position: absolute;
  width: 100rpx;
  height: 100rpx;
  border-radius: 50%;
  background-color: #3c9cfe;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2rpx 5rpx rgba(0, 0, 0, 0.3);
  z-index: 10;
  transition: transform 0.05s ease-out;
}

.wheel-icon {
  color: white;
  font-size: 32rpx;
}

.direction-btn {
  position: absolute;
  width: 60rpx;
  height: 60rpx;
  border-radius: 50%;
  background-color: rgba(60, 156, 254, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
}

.direction-icon {
  color: white;
  font-size: 30rpx;
}

.direction-up {
  top: 20rpx;
  left: 50%;
  transform: translateX(-50%);
}

.direction-right {
  right: 20rpx;
  top: 50%;
  transform: translateY(-50%);
}

.direction-down {
  bottom: 20rpx;
  left: 50%;
  transform: translateX(-50%);
}

.direction-left {
  left: 20rpx;
  top: 50%;
  transform: translateY(-50%);
}

.zoom-controls {
  display: flex;
  justify-content: center;
  margin-top: 30rpx;
}

.zoom-btn {
  width: 80rpx;
  height: 80rpx;
  border-radius: 50%;
  background-color: #3c9cfe;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 20rpx;
}

.zoom-icon {
  color: white;
  font-size: 40rpx;
}

.status-panel {
  margin-top: 50rpx;
  padding: 20rpx;
  border-radius: 10rpx;
  background-color: #f8f8f8;
  width: 80%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.status-panel text {
  margin: 10rpx 0;
  font-size: 28rpx;
  color: #333;
}
</style>